package com.atguigu.gmall.item.rpc;

import com.atguigu.gmall.common.execption.GmallException;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.item.service.SkuDetailService;
import com.atguigu.gmall.web.SkuDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: SkuDetailController
 * Package: com.atguigu.gmall.item.rpc
 * Description:
 *
 * @Author ltystart
 * @Create 2025/8/23 12:40
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/api/inner/item")
public class SkuDetailController {
    @Autowired
    private SkuDetailService skuDetailService;

    /**
     * 获取商品详情
     * @param skuId
     * @return
     */
    @GetMapping("/detail/{skuId}")
    public Result<SkuDetailVo> skuDetail(@PathVariable("skuId") Long skuId){
        log.info("商品查询服务：正在查询{}号商品信息", skuId);
        SkuDetailVo skuDetailVo = skuDetailService.skuDetail(skuId);
        return Result.ok(skuDetailVo);
    }
}
